#include "StdAfx.h"
#include "libs\include\RF651Device.h"

using namespace RFDevice;

extern "C"
{

	RFDEVICEPROXYDLL RF651Device* CALLING_CONVENTION CreateRF651Device()
	{
		return new RF651Device();
	}

	RFDEVICEPROXYDLL void CALLING_CONVENTION DisposeRF651Device(RF651Device* rf)
	{
		rf->~RF651Device();
		rf = NULL;
	}

	//////////////////////////////////////////////////////////////////////////
	// RF651Device
	//////////////////////////////////////////////////////////////////////////

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF651Device_SetBeginAnalogRange(RF651Device* rf, DWORD dwValue)
	{
		return rf->SetBeginAnalogRange(dwValue);
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF651Device_SetEndAnalogRange(RF651Device* rf, DWORD dwValue)
	{
		return rf->SetEndAnalogRange(dwValue);
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF651Device_SetDualMode(RF651Device* rf)
	{
		return rf->SetDualMode();
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF651Device_MeasureDual(RF651Device* rf, USHORT *lpusValue1, USHORT *lpusValue2)
	{
		return rf->MeasureDual(lpusValue1, lpusValue2);
	}

	RFDEVICEPROXYDLL DWORD CALLING_CONVENTION RF651Device_GetBeginAnalogRange(RF651Device* rf)
	{
		return rf->GetBeginAnalogRange();
	}

	RFDEVICEPROXYDLL DWORD CALLING_CONVENTION RF651Device_GetEndAnalogRange(RF651Device* rf)
	{
		return rf->GetEndAnalogRange();
	}

	//////////////////////////////////////////////////////////////////////////
	// RF65xDevice
	//////////////////////////////////////////////////////////////////////////

	RFDEVICEPROXYDLL LPRF65xUDPPACKET CALLING_CONVENTION RF651Device_GetPack(RF651Device* rf)
	{
		return rf->pack;
	}

	RFDEVICEPROXYDLL void CALLING_CONVENTION RF651Device_SetPack(RF651Device* rf, LPRF65xUDPPACKET pack)
	{
		rf->pack = pack;
	}

	RFDEVICEPROXYDLL void CALLING_CONVENTION RF651Device_BindNetworkAddress(RF651Device* rf, BYTE ucAddress)
	{
		return rf->BindNetworkAddress(ucAddress);
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF651Device_HelloCmd_1(RF651Device* rf, BYTE bAddress, LPRF65xHELLOANSWER lprfHelloAnswer)
	{
		return rf->HelloCmd(bAddress, lprfHelloAnswer);
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF651Device_HelloCmd(RF651Device* rf)
	{
		return rf->HelloCmd();
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF651Device_GetSingleMeasure(RF651Device* rf, USHORT* lpusValue)
	{
		return rf->GetSingleMeasure(lpusValue);
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF651Device_GetSingleDualMeasure8(RF651Device* rf, BYTE* lpbValue)
	{
		return rf->GetSingleDualMeasure8(lpbValue);
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF651Device_GetStreamDualMeasure8(RF651Device* rf, BYTE* lpbValue)
	{
		return rf->GetStreamDualMeasure8(lpbValue);
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF651Device_EthernetOpenPort(RF651Device* rf)
	{
		return rf->EthernetOpenPort();
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF651Device_EthernetGetStreamMeasure(RF651Device* rf)
	{
		return rf->EthernetGetStreamMeasure();
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF651Device_EnableSensor(RF651Device* rf, BOOL bEnable = TRUE)
	{
		return rf->EnableSensor(bEnable);
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF651Device_SetPriority(RF651Device* rf, BYTE ucValue)
	{
		return rf->SetPriority(ucValue);
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF651Device_SetNetworkAddress(RF651Device* rf, BYTE ucValue)
	{
		return rf->SetNetworkAddress(ucValue);
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF651Device_SetBaundRate(RF651Device* rf, DWORD dwValue)
	{
		return rf->SetBaundRate(dwValue);
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF651Device_SetAverageCount(RF651Device* rf, DWORD dwValue)
	{
		return rf->SetAverageCount(dwValue);
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF651Device_SetSamplingPeriod(RF651Device* rf, DWORD dwValue)
	{
		return rf->SetSamplingPeriod(dwValue);
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF651Device_SetNominalValue(RF651Device* rf, DWORD dwValue)
	{
		return rf->SetNominalValue(dwValue);
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF651Device_GetPowerState(RF651Device* rf)
	{
		return rf->GetPowerState();
	}

	RFDEVICEPROXYDLL BYTE CALLING_CONVENTION RF651Device_GetPriority(RF651Device* rf)
	{
		return rf->GetPriority();
	}

	RFDEVICEPROXYDLL BYTE CALLING_CONVENTION RF651Device_GetNetworkAddress(RF651Device* rf)
	{
		return rf->GetNetworkAddress();
	}

	RFDEVICEPROXYDLL DWORD CALLING_CONVENTION RF651Device_GetAverageCount(RF651Device* rf)
	{
		return rf->GetAverageCount();
	}

	RFDEVICEPROXYDLL DWORD CALLING_CONVENTION RF651Device_GetSamplingPeriod(RF651Device* rf)
	{
		return rf->GetSamplingPeriod();
	}

	RFDEVICEPROXYDLL DWORD CALLING_CONVENTION RF651Device_GetNominalValue(RF651Device* rf)
	{
		return rf->GetNominalValue();
	}	

	RFDEVICEPROXYDLL LPRF65xPARAMS CALLING_CONVENTION RF651Device_GetParams(RF651Device* rf)
	{
		return rf->GetParams();
	}

	RFDEVICEPROXYDLL BYTE CALLING_CONVENTION RF651Device_GetDeviceType(RF651Device* rf)
	{
		return rf->GetDeviceType();
	}

	RFDEVICEPROXYDLL BYTE CALLING_CONVENTION RF651Device_GetDeviceModificaton(RF651Device* rf)
	{
		return rf->GetDeviceModificaton();
	}

	RFDEVICEPROXYDLL WORD CALLING_CONVENTION RF651Device_GetDeviceSerial(RF651Device* rf)
	{
		return rf->GetDeviceSerial();
	}

	RFDEVICEPROXYDLL WORD CALLING_CONVENTION RF651Device_GetDeviceMaxDistance(RF651Device* rf)
	{
		return rf->GetDeviceMaxDistance();
	}

	RFDEVICEPROXYDLL WORD CALLING_CONVENTION RF651Device_GetDeviceRange(RF651Device* rf)
	{
		return rf->GetDeviceRange();
	}

	//////////////////////////////////////////////////////////////////////////
	// RComDevice
	//////////////////////////////////////////////////////////////////////////

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF651Device_OpenPort(RF651Device* rf, LPCSTR lpPort_Name, DWORD dwSpeed)
	{
		return rf->OpenPort(lpPort_Name, dwSpeed);
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF651Device_ClosePort(RF651Device* rf)
	{
		return rf->ClosePort();
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF651Device_ReadParameter(RF651Device* rf, BYTE bAddress, WORD wParameter, DWORD* lpdwValue)
	{
		return rf->ReadParameter(bAddress, wParameter, lpdwValue);
	}
	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF651Device_WriteParameter(RF651Device* rf, BYTE bAddress, WORD wParameter, DWORD dwValue)
	{
		return rf->WriteParameter(bAddress, wParameter, dwValue);
	}
	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF651Device_ReadCustomParameter(RF651Device* rf, BYTE bAddress, BYTE bParameterAddress, BYTE bParameterSize, void* lpValue)
	{
		return rf->ReadCustomParameter(bAddress, bParameterAddress, bParameterSize, lpValue);
	}
	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF651Device_WriteCustomParameter(RF651Device* rf, BYTE bAddress, BYTE bParameterAddress, BYTE bParameterSize, void* lpValue)
	{
		return rf->WriteCustomParameter(bAddress, bParameterAddress, bParameterSize, lpValue);
	}
	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF651Device_FlushToFlash(RF651Device* rf, BYTE bAddress)
	{
		return rf->FlushToFlash(bAddress);
	}
	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF651Device_RestoreFromFlash(RF651Device* rf, BYTE bAddress)
	{
		return rf->RestoreFromFlash(bAddress);
	}
	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF651Device_LockResult(RF651Device* rf, BYTE bAddress)
	{
		return rf->LockResult(bAddress);
	}
	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF651Device_Measure(RF651Device* rf, BYTE bAddress, USHORT* lpusValue)
	{
		return rf->Measure(bAddress, lpusValue);
	}
	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF651Device_StartStream(RF651Device* rf)
	{
		return rf->StartStream();
	}
	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF651Device_StopStream(RF651Device* rf)
	{
		return rf->StopStream();
	}
	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF651Device_GetStreamMeasure(RF651Device* rf, USHORT* lpusValue)
	{
		return rf->GetStreamMeasure(lpusValue);
	}
	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF651Device_CustomCmd(RF651Device* rf, char * pcInData, DWORD dwInSize, char * pcOutData, DWORD * pdwOutSize)
	{
		return rf->CustomCmd(pcInData, dwInSize, pcOutData, pdwOutSize);
	}
	RFDEVICEPROXYDLL HANDLE CALLING_CONVENTION RF651Device_GetPortHandle(RF651Device* rf)
	{
		return rf->GetPortHandle();
	}
	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF651Device_ValidateData(LPBYTE lpucData, const int nDataLength)
	{
		return RF651Device::ValidateData(lpucData, nDataLength);
	}	

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF651Device_EthernetSetTimeout(RF651Device* rf, DWORD dwTimeout)
	{
		return rf->EthernetSetTimeout(dwTimeout);
	}
	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF651Device_EthernetClosePort(RF651Device* rf)
	{
		return rf->EthernetClosePort();
	}

}